package com.dynamixsoftware.printershare.smb.util;

public class DES
{
  private static int[] SP1 = { 16843776, 0, 65536, 16843780, 16842756, 66564, 4, 65536, 1024, 16843776, 16843780, 1024, 16778244, 16842756, 16777216, 4, 1028, 16778240, 16778240, 66560, 66560, 16842752, 16842752, 16778244, 65540, 16777220, 16777220, 65540, 0, 1028, 66564, 16777216, 65536, 16843780, 4, 16842752, 16843776, 16777216, 16777216, 1024, 16842756, 65536, 66560, 16777220, 1024, 4, 16778244, 66564, 16843780, 65540, 16842752, 16778244, 16777220, 1028, 66564, 16843776, 1028, 16778240, 16778240, 0, 65540, 66560, 0, 16842756 };
  private static int[] SP2 = { -2146402272, -2147450880, 32768, 1081376, 1048576, 32, -2146435040, -2147450848, -2147483616, -2146402272, -2146402304, -2147483648, -2147450880, 1048576, 32, -2146435040, 1081344, 1048608, -2147450848, 0, -2147483648, 32768, 1081376, -2146435072, 1048608, -2147483616, 0, 1081344, 32800, -2146402304, -2146435072, 32800, 0, 1081376, -2146435040, 1048576, -2147450848, -2146435072, -2146402304, 32768, -2146435072, -2147450880, 32, -2146402272, 1081376, 32, 32768, -2147483648, 32800, -2146402304, 1048576, -2147483616, 1048608, -2147450848, -2147483616, 1048608, 1081344, 0, -2147450880, 32800, -2147483648, -2146435040, -2146402272, 1081344 };
  private static int[] SP3 = { 520, 134349312, 0, 134348808, 134218240, 0, 131592, 134218240, 131080, 134217736, 134217736, 131072, 134349320, 131080, 134348800, 520, 134217728, 8, 134349312, 512, 131584, 134348800, 134348808, 131592, 134218248, 131584, 131072, 134218248, 8, 134349320, 512, 134217728, 134349312, 134217728, 131080, 520, 131072, 134349312, 134218240, 0, 512, 131080, 134349320, 134218240, 134217736, 512, 0, 134348808, 134218248, 131072, 134217728, 134349320, 8, 131592, 131584, 134217736, 134348800, 134218248, 520, 134348800, 131592, 8, 134348808, 131584 };
  private static int[] SP4 = { 8396801, 8321, 8321, 128, 8396928, 8388737, 8388609, 8193, 0, 8396800, 8396800, 8396929, 129, 0, 8388736, 8388609, 1, 8192, 8388608, 8396801, 128, 8388608, 8193, 8320, 8388737, 1, 8320, 8388736, 8192, 8396928, 8396929, 129, 8388736, 8388609, 8396800, 8396929, 129, 0, 0, 8396800, 8320, 8388736, 8388737, 1, 8396801, 8321, 8321, 128, 8396929, 129, 1, 8192, 8388609, 8193, 8396928, 8388737, 8193, 8320, 8388608, 8396801, 128, 8388608, 8192, 8396928 };
  private static int[] SP5 = { 256, 34078976, 34078720, 1107296512, 524288, 256, 1073741824, 34078720, 1074266368, 524288, 33554688, 1074266368, 1107296512, 1107820544, 524544, 1073741824, 33554432, 1074266112, 1074266112, 0, 1073742080, 1107820800, 1107820800, 33554688, 1107820544, 1073742080, 0, 1107296256, 34078976, 33554432, 1107296256, 524544, 524288, 1107296512, 256, 33554432, 1073741824, 34078720, 1107296512, 1074266368, 33554688, 1073741824, 1107820544, 34078976, 1074266368, 256, 33554432, 1107820544, 1107820800, 524544, 1107296256, 1107820800, 34078720, 0, 1074266112, 1107296256, 524544, 33554688, 1073742080, 524288, 0, 1074266112, 34078976, 1073742080 };
  private static int[] SP6 = { 536870928, 541065216, 16384, 541081616, 541065216, 16, 541081616, 4194304, 536887296, 4210704, 4194304, 536870928, 4194320, 536887296, 536870912, 16400, 0, 4194320, 536887312, 16384, 4210688, 536887312, 16, 541065232, 541065232, 0, 4210704, 541081600, 16400, 4210688, 541081600, 536870912, 536887296, 16, 541065232, 4210688, 541081616, 4194304, 16400, 536870928, 4194304, 536887296, 536870912, 16400, 536870928, 541081616, 4210688, 541065216, 4210704, 541081600, 0, 541065232, 16, 16384, 541065216, 4210704, 16384, 4194320, 536887312, 0, 541081600, 536870912, 4194320, 536887312 };
  private static int[] SP7 = { 2097152, 69206018, 67110914, 0, 2048, 67110914, 2099202, 69208064, 69208066, 2097152, 0, 67108866, 2, 67108864, 69206018, 2050, 67110912, 2099202, 2097154, 67110912, 67108866, 69206016, 69208064, 2097154, 69206016, 2048, 2050, 69208066, 2099200, 2, 67108864, 2099200, 67108864, 2099200, 2097152, 67110914, 67110914, 69206018, 69206018, 2, 2097154, 67108864, 67110912, 2097152, 69208064, 2050, 2099202, 69208064, 2050, 67108866, 69208066, 69206016, 2099200, 0, 2, 69208066, 0, 2099202, 69206016, 2048, 67108866, 67110912, 2048, 2097154 };
  private static int[] SP8 = { 268439616, 4096, 262144, 268701760, 268435456, 268439616, 64, 268435456, 262208, 268697600, 268701760, 266240, 268701696, 266304, 4096, 64, 268697600, 268435520, 268439552, 4160, 266240, 262208, 268697664, 268701696, 4160, 0, 0, 268697664, 268435520, 268439552, 266304, 262144, 266304, 262144, 268701696, 4096, 64, 268697664, 4096, 266304, 268439552, 64, 268435520, 268697600, 268697664, 268435456, 262144, 268439616, 0, 268701760, 262208, 268435520, 268697600, 268439552, 268439616, 0, 268701760, 266240, 266240, 4160, 4160, 262208, 268435456, 268701696 };
  private static int[] bigbyte;
  private static byte[] bytebit = { -128, 64, 32, 16, 8, 4, 2, 1 };
  private static byte[] pc1;
  private static byte[] pc2;
  private static int[] totrot;
  private int[] decryptKeys = new int[32];
  private int[] encryptKeys = new int[32];
  private int[] tempInts = new int[2];
  
  static
  {
    bigbyte = new int[] { 8388608, 4194304, 2097152, 1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };
    pc1 = new byte[] { 56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 };
    totrot = new int[] { 1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28 };
    pc2 = new byte[] { 13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9, 22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1, 40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47, 43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
  }
  
  public DES() {}
  
  public DES(byte[] paramArrayOfByte)
  {
    if (paramArrayOfByte.length == 7)
    {
      byte[] arrayOfByte = new byte[8];
      makeSMBKey(paramArrayOfByte, arrayOfByte);
      setKey(arrayOfByte);
      return;
    }
    setKey(paramArrayOfByte);
  }
  
  private void cookey(int[] paramArrayOfInt1, int[] paramArrayOfInt2)
  {
    int i = 0;
    int j = 0;
    int k = 0;
    while (i < 16)
    {
      int m = k + 1;
      int n = paramArrayOfInt1[k];
      k = m + 1;
      int i1 = paramArrayOfInt1[m];
      paramArrayOfInt2[j] = ((n & 0xFC0000) << 6);
      paramArrayOfInt2[j] |= (n & 0xFC0) << 10;
      paramArrayOfInt2[j] |= (i1 & 0xFC0000) >>> 10;
      paramArrayOfInt2[j] |= (i1 & 0xFC0) >>> 6;
      int i2 = j + 1;
      paramArrayOfInt2[i2] = ((n & 0x3F000) << 12);
      paramArrayOfInt2[i2] |= (n & 0x3F) << 16;
      paramArrayOfInt2[i2] |= (i1 & 0x3F000) >>> 4;
      paramArrayOfInt2[i2] |= i1 & 0x3F;
      j = i2 + 1;
      i++;
    }
  }
  
  private void des(int[] paramArrayOfInt1, int[] paramArrayOfInt2, int[] paramArrayOfInt3)
  {
    int i = paramArrayOfInt1[0];
    int j = paramArrayOfInt1[1];
    int k = 0xF0F0F0F & (j ^ i >>> 4);
    int m = j ^ k;
    int n = i ^ k << 4;
    int i1 = 0xFFFF & (m ^ n >>> 16);
    int i2 = m ^ i1;
    int i3 = n ^ i1 << 16;
    int i4 = 0x33333333 & (i3 ^ i2 >>> 2);
    int i5 = i3 ^ i4;
    int i6 = i2 ^ i4 << 2;
    int i7 = 0xFF00FF & (i5 ^ i6 >>> 8);
    int i8 = i5 ^ i7;
    int i9 = i6 ^ i7 << 8;
    int i10 = i9 << 1 | 0x1 & i9 >>> 31;
    int i11 = 0xAAAAAAAA & (i8 ^ i10);
    int i12 = i8 ^ i11;
    int i13 = i10 ^ i11;
    int i14 = i12 << 1 | 0x1 & i12 >>> 31;
    int i15 = 0;
    int i16 = 0;
    while (i15 < 8)
    {
      int i33 = i13 << 28 | i13 >>> 4;
      int i34 = i16 + 1;
      int i35 = i33 ^ paramArrayOfInt3[i16];
      int i36 = SP7[(i35 & 0x3F)] | SP5[(0x3F & i35 >>> 8)] | SP3[(0x3F & i35 >>> 16)] | SP1[(0x3F & i35 >>> 24)];
      int i37 = i34 + 1;
      int i38 = i13 ^ paramArrayOfInt3[i34];
      i14 ^= (i36 | SP8[(i38 & 0x3F)] | SP6[(0x3F & i38 >>> 8)] | SP4[(0x3F & i38 >>> 16)] | SP2[(0x3F & i38 >>> 24)]);
      int i39 = i14 << 28 | i14 >>> 4;
      int i40 = i37 + 1;
      int i41 = i39 ^ paramArrayOfInt3[i37];
      int i42 = SP7[(i41 & 0x3F)] | SP5[(0x3F & i41 >>> 8)] | SP3[(0x3F & i41 >>> 16)] | SP1[(0x3F & i41 >>> 24)];
      i16 = i40 + 1;
      int i43 = i14 ^ paramArrayOfInt3[i40];
      i13 ^= (i42 | SP8[(i43 & 0x3F)] | SP6[(0x3F & i43 >>> 8)] | SP4[(0x3F & i43 >>> 16)] | SP2[(0x3F & i43 >>> 24)]);
      i15++;
    }
    int i17 = i13 << 31 | i13 >>> 1;
    int i18 = 0xAAAAAAAA & (i14 ^ i17);
    int i19 = i14 ^ i18;
    int i20 = i17 ^ i18;
    int i21 = i19 << 31 | i19 >>> 1;
    int i22 = 0xFF00FF & (i20 ^ i21 >>> 8);
    int i23 = i20 ^ i22;
    int i24 = i21 ^ i22 << 8;
    int i25 = 0x33333333 & (i23 ^ i24 >>> 2);
    int i26 = i23 ^ i25;
    int i27 = i24 ^ i25 << 2;
    int i28 = 0xFFFF & (i27 ^ i26 >>> 16);
    int i29 = i27 ^ i28;
    int i30 = i26 ^ i28 << 16;
    int i31 = 0xF0F0F0F & (i29 ^ i30 >>> 4);
    int i32 = i29 ^ i31;
    paramArrayOfInt2[0] = (i30 ^ i31 << 4);
    paramArrayOfInt2[1] = i32;
  }
  
  private void deskey(byte[] paramArrayOfByte, boolean paramBoolean, int[] paramArrayOfInt)
  {
    int[] arrayOfInt1 = new int[56];
    int[] arrayOfInt2 = new int[56];
    int[] arrayOfInt3 = new int[32];
    int i = 0;
    if (i < 56)
    {
      int i5 = pc1[i];
      int i6 = i5 & 0x7;
      if ((paramArrayOfByte[(i5 >>> 3)] & bytebit[i6]) != 0) {}
      for (int i7 = 1;; i7 = 0)
      {
        arrayOfInt1[i] = i7;
        i++;
        break;
      }
    }
    for (int j = 0; j < 16; j++)
    {
      int k;
      int m;
      int n;
      label122:
      int i4;
      if (paramBoolean)
      {
        k = j << 1;
        m = k + 1;
        arrayOfInt3[m] = 0;
        arrayOfInt3[k] = 0;
        n = 0;
        if (n >= 28) {
          break label191;
        }
        i4 = n + totrot[j];
        if (i4 >= 28) {
          break label175;
        }
        arrayOfInt2[n] = arrayOfInt1[i4];
      }
      for (;;)
      {
        n++;
        break label122;
        k = 15 - j << 1;
        break;
        label175:
        arrayOfInt2[n] = arrayOfInt1[(i4 - 28)];
      }
      label191:
      int i1 = 28;
      if (i1 < 56)
      {
        int i3 = i1 + totrot[j];
        if (i3 < 56) {
          arrayOfInt2[i1] = arrayOfInt1[i3];
        }
        for (;;)
        {
          i1++;
          break;
          arrayOfInt2[i1] = arrayOfInt1[(i3 - 28)];
        }
      }
      for (int i2 = 0; i2 < 24; i2++)
      {
        if (arrayOfInt2[pc2[i2]] != 0) {
          arrayOfInt3[k] |= bigbyte[i2];
        }
        if (arrayOfInt2[pc2[(i2 + 24)]] != 0) {
          arrayOfInt3[m] |= bigbyte[i2];
        }
      }
    }
    cookey(arrayOfInt3, paramArrayOfInt);
  }
  
  private void encrypt(byte[] paramArrayOfByte1, int paramInt1, byte[] paramArrayOfByte2, int paramInt2)
  {
    squashBytesToInts(paramArrayOfByte1, paramInt1, this.tempInts, 0, 2);
    des(this.tempInts, this.tempInts, this.encryptKeys);
    spreadIntsToBytes(this.tempInts, 0, paramArrayOfByte2, paramInt2, 2);
  }
  
  private static void makeSMBKey(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
  {
    paramArrayOfByte2[0] = ((byte)(0xFF & paramArrayOfByte1[0] >> 1));
    paramArrayOfByte2[1] = ((byte)(0xFF & ((0x1 & paramArrayOfByte1[0]) << 6 | 0xFF & (0xFF & paramArrayOfByte1[1]) >> 2)));
    paramArrayOfByte2[2] = ((byte)(0xFF & ((0x3 & paramArrayOfByte1[1]) << 5 | 0xFF & (0xFF & paramArrayOfByte1[2]) >> 3)));
    paramArrayOfByte2[3] = ((byte)(0xFF & ((0x7 & paramArrayOfByte1[2]) << 4 | 0xFF & (0xFF & paramArrayOfByte1[3]) >> 4)));
    paramArrayOfByte2[4] = ((byte)(0xFF & ((0xF & paramArrayOfByte1[3]) << 3 | 0xFF & (0xFF & paramArrayOfByte1[4]) >> 5)));
    paramArrayOfByte2[5] = ((byte)(0xFF & ((0x1F & paramArrayOfByte1[4]) << 2 | 0xFF & (0xFF & paramArrayOfByte1[5]) >> 6)));
    paramArrayOfByte2[6] = ((byte)(0xFF & ((0x3F & paramArrayOfByte1[5]) << 1 | 0xFF & (0xFF & paramArrayOfByte1[6]) >> 7)));
    paramArrayOfByte2[7] = ((byte)(0x7F & paramArrayOfByte1[6]));
    for (int i = 0; i < 8; i++) {
      paramArrayOfByte2[i] = ((byte)(paramArrayOfByte2[i] << 1));
    }
  }
  
  private static void spreadIntsToBytes(int[] paramArrayOfInt, int paramInt1, byte[] paramArrayOfByte, int paramInt2, int paramInt3)
  {
    for (int i = 0; i < paramInt3; i++)
    {
      paramArrayOfByte[(paramInt2 + i * 4)] = ((byte)(paramArrayOfInt[(paramInt1 + i)] >>> 24));
      paramArrayOfByte[(1 + (paramInt2 + i * 4))] = ((byte)(paramArrayOfInt[(paramInt1 + i)] >>> 16));
      paramArrayOfByte[(2 + (paramInt2 + i * 4))] = ((byte)(paramArrayOfInt[(paramInt1 + i)] >>> 8));
      paramArrayOfByte[(3 + (paramInt2 + i * 4))] = ((byte)paramArrayOfInt[(paramInt1 + i)]);
    }
  }
  
  private static void squashBytesToInts(byte[] paramArrayOfByte, int paramInt1, int[] paramArrayOfInt, int paramInt2, int paramInt3)
  {
    for (int i = 0; i < paramInt3; i++) {
      paramArrayOfInt[(paramInt2 + i)] = ((0xFF & paramArrayOfByte[(paramInt1 + i * 4)]) << 24 | (0xFF & paramArrayOfByte[(1 + (paramInt1 + i * 4))]) << 16 | (0xFF & paramArrayOfByte[(2 + (paramInt1 + i * 4))]) << 8 | 0xFF & paramArrayOfByte[(3 + (paramInt1 + i * 4))]);
    }
  }
  
  public void encrypt(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
  {
    encrypt(paramArrayOfByte1, 0, paramArrayOfByte2, 0);
  }
  
  public void setKey(byte[] paramArrayOfByte)
  {
    deskey(paramArrayOfByte, true, this.encryptKeys);
    deskey(paramArrayOfByte, false, this.decryptKeys);
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.smb.util.DES
 * JD-Core Version:    0.7.0.1
 */